package com.dxc.intern.entity;

import lombok.Data;
import org.springframework.http.HttpStatus;
@Data
public class Result<T> {

    private long timestamp = System.currentTimeMillis();
    private String message = "";
    private int code = 0;
    private T result;

    public static <T>  Result<T> success(String message, T data){
        Result<T> result = new Result<T>();
        result.setMessage(message);
        result.setCode(HttpStatus.OK.value());
        result.setResult(data);
        return result;

    }

    public static <T>  Result<T> error(String message, T data){
        Result<T> result = new Result<T>();
        result.setMessage(message);
        result.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
        result.setResult(data);
        return result;
    }
}
